home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 2
/
Merciful - Disc 2.iso
/
software
/
h
/
highspeedpascalv2.0a.dms
/
highspeedpascalv2.0a.adf
/
HSPascal
/
AmigaDemos
/
WindowDemo.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-12-31
|
7KB
|
150 lines
{--------------------------------------------------------------------------
HighSpeed Pascal for the Amiga
WINDOW DEMO
Programmed by Martin Eskildsen 1991
Copyright (c) 1991 by D-House I ApS
All rights reserved
Version : Date (dd.mm.yy) : Comment
-----------------------------------
1.00 : 20.07.91 : First version
1.01 : 17.09.91 : Modified for new libraries
1.02 : 06.11.91 : Final for first release
--------------------------------------------------------------------------}
program WindowDemo;
uses Init, Intuition, Graphics;
label
1; { Disaster branch-out }
const
MaxWindows = 7; { Can't do more because of screen size }
var
w1def : tNewWindow; { Defs for window 1 }
wdef : tNewWindow; { Defs for other windows }
w : array [1..MaxWindows] of pWindow; { Window records }
i, j : integer; { Index }
begin
if PrepareEnvironment('Window') then begin { Init Demo environment }
Message('First, a simple window with borders only');
with w1def do begin { Set up window: }
LeftEdge := 20;
TopEdge := Init.TopOffset; { Start below info window }
Width := 210;
Height := 75;
DetailPen := 0; { Color to use for details }
BlockPen := 1; { and blocks }
Title := NIL; { Window has no title bar, so NIL }
Flags := SMART_REFRESH or { Save parts in RAM }
NOCAREREFRESH; { Don't want no refresh messages }
IDCMPflags := 0; { Don't want any messages at all! }
Type_ := CUSTOMSCREEN; { Put it on the CUSTOMSCREEN }
FirstGadget := NIL; { No gadgets attached }
CheckMark := NIL; { Usual check mark }
Screen := Init.BaseScreen; { The custom screen to use }
BitMap := NIL; { No special bitmap for window }
MinWidth := Width; { Values for user's resizing of }
MinHeight := Height; { window. Aren't used here as the }
MaxWidth := MinWidth; { window can't be resized }
MaxHeight := MaxHeight
end;
w[1] := OpenWindow(@w1def); { Open the window }
if Panic(w[1] = NIL, 'Could not open window 1!') { Couldn't! }
then goto 1; { Let's get out of here! }
with w[1]^ do begin { Put some text in the window: }
Move_(RPort, 10,20); { (x,y) for lower left corner }
Text_(RPort, 'Window with borders only', { The string to write }
24) { The length of the string! }
end;
Message('Then with the usual gadgets');
wdef := w1def; { Use same def as w[1] }
with wdef do begin { but change it a bit: }
inc(TopEdge, 15); { Move a bit down and }
inc(LeftEdge, 15); { to the right }
MinWidth := 40; { Make it resizable }
MinHeight := 20;
MaxWidth := Init.ScrWidth;
MaxHeight := Init.ScrHeight;
flags := flags or WINDOWCLOSE or { Want the Close gadget, }
WINDOWDRAG or { drag gadget, }
WINDOWDEPTH or { depth arrangement gadgets, }
WINDOWSIZING; { size gadget, too }
IDCMPflags := CLOSEWINDOW_; { Want to know if user }
{ clicked the Close gadget. }
{ Note the underscore '_' }
Title := CStrConstPtr('Window 2'#0)
end;
w[2] := OpenWindow(@wdef); { Open window 2 }
if Panic(w[2] = NIL, 'Could not open window 2!') then goto 1;
DisableClose(w[2]);
{ This is funny! Now, if I want to be able to sense the Close gadget I have
to have the IDCMPflags set when opening the window. But I don't want to
sense this message right now, so I clear the CLOSEWINDOW_ flag immediately
upon creating the window.
This makes the program behave properly if the user clicks the "wrong"
Close gadget (i.e. in the wrong window) when there are two windows on the
screen. Try to remove DisableClose and play around with the Close clicks }
Message('Nice name, right? Let''s call it something else');
SetWindowTitles(w[2],
CStrConstPtr('Forty-two!'),
ptr(-1)); { Don't change screen title }
Inform('Say good-bye to window 2 by clicking its Close gadget');
WaitClose(w[2]); { Wait for user to click Close gadget }
CloseWindow(w[2]); { Close window 2 }
Message('The application can resize the window (now six times)');
for i := 1 to 6 do SizeWindow(w[1], 20, 10); { Delta x and y }
Message('And change its position ten times 20 pixels');
for i := 1 to 10 do MoveWindow(w[1], 20, 0); { Delta x and y }
Message('Seen enough of that window, right? Let''s throw it away!');
CloseWindow(w[1]);
Message('We shall now create a "stack" of windows');
wdef := w1def;
wdef.flags := wdef.flags or WINDOWDRAG or WINDOWDEPTH;
for i := 1 to MaxWindows do begin
with wdef do begin
inc(TopEdge, 10);
inc(LeftEdge, 20);
Title := CStrConstPtr('Window ' + chr(i + ord('@')) + #0)
end;
w[i] := OpenWindow(@wdef);
if Panic(w[i] = NIL, 'Error while opening a window!') then goto 1;
with w[i]^ do begin { Put text in window }
Graphics.Move_(RPort, 3, 20); { at (3,20) }
for j := 1 to 24 do { 24 letters: Window 1 = AAAAA... }
{ Window 2 = BBBBB... etc. }
Graphics.Text_(RPort, chr(i + ord('@')), 1)
end
end;
Message('Now the application will "cycle" the stack');
for i := MaxWindows downto 1 do WindowToFront(w[i]);
Message('Phew! Let''s close those windows again');
for i := MaxWindows downto 1 do CloseWindow(w[i]);
1: { Where to go if the world gets "funny" }
CloseDown { Deinit Demo environment }
end
end.